import request from "@/request/request"
import requestMock from "@/request/requestMock"

// 1. 请求三级分类列表
export const reqCategoryList = () => {
  return request.get("/product/getBaseCategoryList")
}

// 2.使用mock模拟发起bannerList请求
export const reqBannerList = () => {
  return requestMock.get("/banner/list")
}
// 3.使用mock模拟发起floorList请求
export const reqFloorList = () => {
  return requestMock.get("/floor/list")
}

// 4.请求searchList数据
export const reqSearchList = (searchParams) => {
  return request.post(`/list`, searchParams)
}

//5.请求商品详情的数据
export const reqDetailInfo = (skuId) => {
  return request.get(`/item/ ${skuId} `)
}

//6.请求详情页已选择完毕的商品数据
export const reqOrupdateShopCart = (skuId, skuNum) => {
  return request.post(`/cart/addToCart/${skuId}/${skuNum}`)
}

//7.请求购物车列表数据
export const reqShopCartList = () => {
  return request.get(`/cart/cartList`)
}

//8.修改选中状态后请求最新数据
export const reqCartGoodsIsChecked = (skuID, isChecked) => {
  return request.get(`/cart/checkCart/${skuID}/${isChecked}`)
}

//9.删除单个购物车商品的请求
export const reqDeleteSingleGoods = (skuId) => {
  return request.delete(`/cart/deleteCart/${skuId}`)
}

//10.控制购物车所有商品的状态（全选和反选）
export const reqAllChecked = (isChecked, skuIdList) => {
  return request.post(`/cart/batchCheckCart/${isChecked}`, skuIdList)
}

//11. 批量删除购物车数据
export const reqDeleteAllChecked = (skuIdList) => {
  return request.delete(`/cart/batchDeleteCart`, {
    data: skuIdList,
  })
}

//12.获取验证码的请求
export const reqVerifyCode = (phone) => {
  return request.get(`/user/passport/sendCode/${phone}`)
}

//13.注册账号的请求
export const reqRegister = (userInfo) => {
  return request.post(`/user/passport/register`, userInfo)
}

//14.登录请求
export const reqLogin = (userInfo) => {
  return request.post(`/user/passport/login`, userInfo)
}

//15.请求用户信息
export const reqUserInfo = () => {
  return request.get(`/user/passport/auth/getUserInfo`)
}

//16.退出登录
export const reqLogout = () => {
  return request.get(`/user/passport/logout`)
}

//17.请求用户地址
export const reqUserAddress = () => {
  return requestMock.get(`/address/list`)
}

//18.请求交易页的信息
export const reqTradeInfo = () => {
  return request.get(`/order/auth/trade`)
}

//19.请求交易页的信息
export const reqSubmitOrder = (tradeNo, orderInfo) => {
  return request.post(`/order/auth/submitOrder?tradeNo=${tradeNo}`, orderInfo)
}

//20.请求支付详情数据
export const reqPayInfo = (orderId) => {
  return request.get(`/payment/weixin/createNative/${orderId}`)
}

//21.获取支付成功的信息
export const reqPayStatus = (orderId) => {
  return request.get(`/payment/weixin/queryPayStatus/${orderId}`)
}

//22.请求订单数据
export const reqOrderList = (page,limit) => {
  return request.get(`/order/auth/${page}/${limit}`)
}
